use cri_api::v1::{ListContainersRequest};
use cri_api::v1::runtime_service_client::RuntimeServiceClient;
use tokio::net::UnixStream;
use tonic::transport::{Endpoint, Uri};
use tower::service_fn;
use tokio::main;

#[tokio::main]
async fn main() {
    let path = "/run/containerd/containerd.sock";
    let channel = Endpoint::try_from("http://[::]")
        .unwrap()
        .connect_with_connector(service_fn(move |_: Uri| UnixStream::connect(path)))
        .await
        .expect("Could not create client.");

    let mut client = RuntimeServiceClient::new(channel);

    let request = ListContainersRequest {
        filter: None
    };

    let response =  client.list_containers(request).await;
    println!("{:#?}", response);
}
